home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
basinfo.arc
/
BASINFO.DOC
Wrap
Text File
|
1985-10-19
|
9KB
|
211 lines
Commonly used Basic Peeks, Pokes and Subroutines
Due to the lack of a comprehensive, published directory of commonly used
pokes, peeks and subroutines this list has been compiled by the SMUG
PROSIG as well as a many other hardworking PD sources. Thanks and a tip
of the hat to all contributors! Additions to the list are encouraged and
should be address to:
Don Watkins, CIS IBMSIG 76003,252
There are, of course no warrenties or guarentees that any of stuff works
and furthermore, if it blows up your machine it ain't my fault.
------------------------------------------------------------------------
By specifying a DEF SEG=&H40 in any BASIC program, it is possible to
reference the following vectors (fields) in the ROM BIOS area by using a
PEEK function and the following offsets from the current segment as
defined by the DEF SEG statement.
&H0 - RS232 Addresses on your IBM PC.
This will allow you to tell how many (up to
four) async cards are attached, if any.
&H8 - Printer Addresses on your IBM PC.
This will tell you what printer addresses,
and how many (up to four) exist. Each is
addressed by a two byte Hex value.
&H10 - Equipment Flag.
This field describes the setting of the
options switches. It describes what optional
devices are attached to the system. The
following lists the bit-significance of this
field:
Bit 0 - indicates that there are diskette
drives on the system.
Bit 1 - not used.
Bit 2,3 - Planar Ram Size (00=16K 10=32K 01=48K
11=64K)
Bit 4,5 - Initial Video Mode (00=Unused
10=40x25 Color
01=80x25 Color
11=80x25 Mono)
Bit 6,7 - Number of Diskette Drives (00=1 10=2
01=3 11=4) only if bit 0 = 1.
Bit 8 - Unused
Bit 9,10,11 - Number of RS232 Cards attached
Bit 12 - Game I/O Attached
Bit 13 - Not used
Bit 14,15 - Number of printers attached
&H13 - Memory Size in K bytes.
&H15 - I/O RAM Size in K bytes.
&H17 - Keyboard Flag -- the following lists the masks
set to describe current keyboard status:
Byte 1;
&H80 - Insert state active
&H40 - Caps Lock State Has been toggled
&H20 - Num Lock State has been toggled
&H10 - Scroll Lock State has been toggled
&H08 - Alternate Shift key depressed
&H04 - Control Shift key depressed
&H02 - Left Shift key depressed
&H01 - Right Shift key depressed
Byte 2;
&H80 - Insert Key is depressed
&H40 - Caps Lock Key is depressed
&H20 - Num Lock Key is depressed
&H10 - Scroll Lock key is depressed
&H08 - Suspend key has been toggled
&H49 - Current CRT mode
&H00 - 40x25 BW
&H01 - 40x25 Color
&H02 - 80x25 BW
&H03 - 80x25 Color
&H04 - 320x200 Color
&H05 - 320x200 BW
&H06 - 640x200 BW
&H07 - 80x25 B&W Card -- specialized use, used
internal to the video routines.
&H4A - Number of CRT columns
&H50 - Cursor Position (one of eight)
&H60 - Current cursor mode
&H6C - Low word of Timer count
&H6E - High word of Timer count
&H71 - &H07 - Break key depressed
&HFA6E - Beginning of character regen memory
&HFF53 - PRTSC routine address
------------------------------------------------------------------
Real stuff--
TOGGLE NUM LOCK
DEG SEG = &H40 : POKE &H17, PEEK(&H17) OR 32 'To turn on
DEG SEG = &H40 : POKE &H17, PEEK(&H17) AND 223 'To turn off
TOGGLE CAPS LOCK
DEG SEG = &H40 : POKE &H17, PEEK(&H17) OR 64 'To turn on
DEG SEG = &H40 : POKE &H17, PEEK(&H17) AND 171 'To turn off
SET SCROLL WINDOW
10 DEF SEG : POKE 91,20 : POKE 92,25 'Sets up window on line
20 LOCATE X,20 'Force cursor to window
SET WINDOW WIDTH
DEF SEG : POKE 41,30 'Sets window width to 30
RESTORE FUNCTION KEYS TO DEFAULT
10 DEF SEG = &HFACE
20 K = 1
30 I = 13
40 T$ = STRING$(13,32): J = 1
50 T1 = PEEK(I):IF T1 < 0 THEN MID$(T$,J,1) = CHR$(T1):J = J + 1:
I = I + 1 : GOTO 50
60 KEY K,LEFT$(T$,J-1):IF K <10 THEN K = K + 1: I = I + 1: GOTO 40 :
ELSE KEY ON
DETERMINE MONITOR TYPE
10 DEF SEG = 0
20 MONITOR.TYPE = PEEK(&H410) AND &H40
30 IF MONITOR.TYPE = 1 PRINT "40 X 25 COLOR"
40 IF MONITOR.TYPE = 32 PRINT "80 X 25 COLOR"
50 IF MONITOR.TYPE = 48 PRINT "MONOCHROME"
DETERMINE AMOUNT OF MEMORY INSTALLED (Only works for greater than 48k)
DEF SEG = 0: MEMORY% = PEEK(&H413)+(256*PEEK(&H414))
or, put another way:
Memory info: DEF SEG=0
((PEEK(1040) and 12) + 4 ) * 4 - Memory on Mother-board
PEEK(1045) + 256 * PEEK(1046) - Expansion memory (add on)
PEEK(1043) + 256 * PEEK(1044) - Total memory
READ DRIVE SWITCHES
DEF SEG = 0: NUMBER.OF.DRIVES% = PEEK(&H410) AND &HC0
CURRENT DISK INFO: DEF SEG=64
DEF SEG=64
PEEK(69) - Track
PEEK(70) - Head
PEEK(71) - Sector
256^PEEK(72) - Bytes per sector
DETERMINE IF GAME ADAPTER EXISTS
10 DEF SEG = 0: GAME.ADAPTER% = PEEK(&H411) AND &H10
20 IF GAME.ADAPTER% = 0 THEN GAME.ADAPTER$ = "No" ELSE GAME.ADAPTER$
= "Yes --Installed"
KEYBOARD STUFF
To disable entire keyboard: Def Seg=64: Out 97,204
To re-enable keyboard: Def Seg=64: Out 97,76
Printer Status--- at least on Epson ---
Def Seg=64
A=peek(8)+256*peek(9)
B=(inp(a+1) and 248) xor 72
if (B and 128)<>128 then printer off line else on line
Initialize Printer: Def Seg: Out A+2,8
Out A+2,12
Note: the A to initialize is from Printer status routine
A short program to disable and re-enable ctrl break follows.
100 DIM OLD%(4)
110 DEF SEG=0
120 ' save the old control break address
130 FOR I=&H6C TO &H6F
140 OLD%(I-&H6C)=PEEK(I)
150 NEXT
160 ' establish new control break address (point to IRET)
170 POKE &H6C,&H53
180 POKE &H6D,&HFF
190 POKE &H6E,&H0
200 POKE &H6F,&HF0
210 DEF SEG
220 ' reset old control break address
230 DEF SEG=0
240 FOR I=&H6C TO &H6F
250 POKE I,OLD%(I-&H6C)
260 NEXT
Save and Restore a Screen Image
1 DEF SEG = &HB800 'Save screen image...change for
2 INPUT FILENAME$ 'monochrome.
3 BSAVE FILENAME$,0,&H4000
1000 INPUT "Filename";FILENAME$ 'Restore image
1010 CLS
1020 DEF SEG = &HB800 'Change to &HB000 to mono
1030 BLOAD FILENAME$
Nice to know
BASIC Unprotect
Enter BASICA
Type BSAVE "UN.P",1124,1
Load "MYPROG
BLOAD "UN.P",1124
The program can now be listed, edited and SAVEd as a normal file.
The list is growing but could be longer! Any and all additions of
commonly used subroutines and peek/poke locations will be gladly added.
Address all additions to: Don Watkins CIS 76003,252 (IBMSIG). With a
bit of your assistance this document can become an effective tool for the
BASIC programmer.... so chip in.
bit of your assistance this doc